import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)
// 解决反复获取同一份数据的错误
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


const routes = [
  {
    path: '/',
    name: 'main',
    component: () => import('../views/Main.vue'),
    // 二级路由
    children: [
      {
        path: '/Home',
        alias: '',
        name: 'home',
        component: () => import('../views/Home.vue'),
        // 三级路由
        children: [
          {
            path: '/Attention',
            name: 'attention',
            component: () => import('../components/Attention.vue'),
          },
          {
            path: '/Recommend',
            alias: '',
            name: 'recommend',
            component: () => import('../components/Recommend.vue'),
          },
          {
            path: '/Shipin',
            name: 'shipin',
            component: () => import('../components/Shipin.vue'),
          },
        ]
      },

      {
        path: '/Collect',
        name: 'collect',
        component: () => import('../views/Collect.vue'),
      },
      {
        path: '/My',
        name: 'my',
        component: () => import('../views/My.vue'),
      }
    ]
  },
  {
    path: '/Menu/:id',
    name: 'menu',
    component: () => import('../views/Menu.vue'),
  },
  {
    path: '/V-menu/:id',
    name: 'v-menu',
    component: () => import('../views/V-menu.vue'),
  },
  {
    path: '/Issue/',
    name: 'issue',
    component: () => import('../views/Issue.vue'),
  },
  {
    path: '/Search/',
    name: 'search',
    component: () => import('../views/Search.vue'),
  },
  {
    path: '/Message/',
    name: 'message',
    component: () => import('../views/Message.vue'),
  },
  {
    path: '/Attentionlist/',
    name: 'attentionlist',
    component: () => import('../views/Attentionlist.vue'),
  },
  {
    path: '/register/',
    name: 'register',
    component: () => import('../views/Register.vue'),
  },

]

const router = new VueRouter({
  routes
})

export default router
